package com.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreferencesUtils {

	private static SharedPreferencesUtils sharedPreferencesUtils = null;
	public static final String PREFS_NAME = "smartmap";
	private static SharedPreferences sharedPreferences = null;
	private SharedPreferences.Editor editor = null;

	private static final String NICKNAME_ALIAS = "nickName";
	private static final String MEMBERID_ALIAS = "memberId";
	private static final String EMAIL_ALIAS = "email";
	private static final String PHONE_ALIAS = "phoneno";
	private static final String PWD_ALIAS = "pwd";
	private static final String DEVICE_ALISA = "deviceId";

	private SharedPreferencesUtils() {

	}

	private SharedPreferencesUtils(Context context) {
		sharedPreferences = context.getSharedPreferences(PREFS_NAME, 0);
	}

	public static SharedPreferencesUtils getInstance(Context context) {
		if (sharedPreferencesUtils == null || sharedPreferences == null) {
			sharedPreferencesUtils = new SharedPreferencesUtils(context);
		}
		return sharedPreferencesUtils;
	}

	public static String getNickName() {
		return sharedPreferences.getString(NICKNAME_ALIAS, "");
	}

	public void setNickName(String nickName) {
		editor = sharedPreferences.edit();
		editor.putString(NICKNAME_ALIAS, nickName);
		editor.commit();
		editor.clear();
	}

	public static String getEmail() {
		return sharedPreferences.getString(EMAIL_ALIAS, "");
	}

	public void setEmail(String email) {
		editor = sharedPreferences.edit();
		editor.putString(EMAIL_ALIAS, email);
		editor.commit();
		editor.clear();
	}

	public static String getPwd() {
		return sharedPreferences.getString(PWD_ALIAS, "");
	}

	public void setPwd(String pwd) {
		editor = sharedPreferences.edit();
		editor.putString(PWD_ALIAS, pwd);
		editor.commit();
		editor.clear();

	}

	public static String getDeviceId() {
		return sharedPreferences.getString(DEVICE_ALISA, "");
	}

	public void setDeviceId(String deviceId) {
		editor = sharedPreferences.edit();
		editor.putString(DEVICE_ALISA, deviceId);
		editor.commit();
		editor.clear();

	}

	public static String getPhone() {
		return sharedPreferences.getString(PHONE_ALIAS, "");
	}

	public void setPhone(String phoneno) {
		editor = sharedPreferences.edit();
		editor.putString(PHONE_ALIAS, phoneno);
		editor.commit();
		editor.clear();
	}

	public static String getMemberId() {
		return sharedPreferences.getString(MEMBERID_ALIAS, "");
	}

	public void setMemberId(String memberId) {
		editor = sharedPreferences.edit();
		editor.putString(MEMBERID_ALIAS, memberId);
		editor.commit();
		editor.clear();
	}

}
